﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LibrarySolution.DAO.基础;
using LibrarySolution.Model.基础;
using LibrarySolution.ComMethod;


namespace LibrarySolution
{
    public partial class FrmLogin : Form
    {
        #region 属性
        GlyDao glyDao = new GlyDao();
        YhDao yhDao = new YhDao();
        #endregion

        #region 构造器
        public FrmLogin()
        {
            InitializeComponent();
        }
        #endregion

        #region 事件
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            GlyEntity glyEntity = new GlyEntity();
            glyEntity = glyDao.doLogin(TxtZh.Text.Trim(), TxtPsw.Text.Trim());
            if (glyEntity != null)
            {
                if (glyEntity.gly_code == "1")
                    GlobalVar.SpGly = true;
                GlobalVar.GlyEntity = glyEntity;
                GlobalVar.NoGly = true;
            }
            else
            {
                YhxxEntity yhxxEntity = new YhxxEntity();
                yhxxEntity.yh_zh = TxtZh.Text.Trim();
                yhxxEntity.yh_pwd = TxtPsw.Text.Trim();
                yhxxEntity = yhDao.doLogin(yhxxEntity);
                if (yhxxEntity.yh_no == null)
                {
                    MessageBox.Show("该账号不存在或密码错误", "警告");
                    return;
                }
                GlobalVar.YhxxEntity = yhxxEntity;
                GlobalVar.YhEnter = true;
            }
            FrmMain frmMain = new FrmMain();
            frmMain.Show();
            GlobalVar.frmMain = frmMain;
            GlobalVar.frmLogin = this;
            this.Hide();
        }
        #endregion
    }
}
